<template>
	<view class="page-box">
		<!-- 搜索框 -->
		<view class="search-box">
			<view class="top-box" @click="GoSearchList">
				<image src="../../static/image/search.png"></image>
				<input placeholder="请输入要搜索的商品"  confirm-type="done" />
			</view>
		</view>
		<swiper  class="swiper"  autoplay="true" interval="3000" duration="500" next-margin="0rpx" previous-margin="0rpx" indicator-dots>
			<swiper-item   class="swiper-item" v-for="(item,index) in swiperList" :key="index">
				<image :src="item.image"></image>
			</swiper-item>
		</swiper>
		<view class="type-box">
			<view class="one-box" @click="GoDetail()">
				<image src="../../static/image/phone.png"></image>
				<text>手机</text>
			</view>
			<view class="one-box">
				<image src="../../static/image/food.png"></image>
				<text>食品</text>
			</view>
			<view class="one-box">
				<image src="../../static/image/cloth.png"></image>
				<text>服饰</text>
			</view>
			<view class="one-box">
				<image src="../../static/image/shoes.png"></image>
				<text>鞋子</text>
			</view>
			<view class="one-box">
				<image src="../../static/image/kouhong.png"></image>
				<text>彩妆</text>
			</view>
			<view class="one-box">
				<image src="../../static/image/sport.png"></image>
				<text>运动</text>
			</view>
			<view class="one-box">
				<image src="../../static/image/bag.png"></image>
				<text>包包</text>
			</view>
			<view class="one-box">
				<image src="../../static/image/cat.png"></image>
				<text>帽子</text>
			</view>
		</view>
		<view class="title">
			<image src="../../static/image/fav.png"></image>
			<text>强烈推荐</text>
		</view>
		<view class="pro-box" v-for="(item,index) in topList" :key="item.id">
			<image :src="item.img"></image>
			<view class="pro-right">
				<view class="ptitle">{{item.title}}</view>
				<view class="bp">{{item.bp}}</view>
				<view class="price">￥{{item.price}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				swiperList:''
			}
		},
		onLoad() {
			let that = this
			that.getSwipertList()
		},
		computed: {
			topList() {
				return this.$store.state.topList || '';
			}
		},
		methods: {
			GoDetail(){
				uni.switchTab({
					url:'/pages/goods/goods'
				})
			},
			getSwipertList(e){
				uniCloud.callFunction({
					name:'swiper',
					data:{
					},
					success: (rest) => {
						console.log('轮播图获取成功')
						this.swiperList = rest.result.data
					},
					fail: (err) => {
						console.log('轮播图获取失败',err)
					}
				})
				},
			GoSearchList(){
				uni.navigateTo({
					url:'/pages/index/search'
				})
				}
		}
	}
</script>

<style scoped lang="scss">
	.swiper{
		height:350rpx;
		display: flex;
		flex-direction:row;
		margin: 0rpx 24rpx;
	}
	.swiper-item{
		border-radius: 12rpx;
		width: 100%;
	}
	image{
		width: 100%;
		height: 100%;
	}
	.top-box{
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 20rpx 24rpx;
		background-color: #FFFFFF;
		border-radius: 50rpx;
		image{
			width: 36rpx;
			height: 36rpx;
			margin-right: 26rpx;
			}
		}
	.type-box{
		margin: 32rpx 24rpx;
		display: flex;
		justify-content:space-between;
		flex-direction: row;
		flex-wrap: wrap;
		background-color: #FFFFFF;
		padding:0rpx 32rpx 32rpx 32rpx;
		border-radius: 12rpx;
		}
	.one-box{
		padding-top: 32rpx;
		width:25%;
		display: flex;
		flex-direction:column;
		align-items: center;
		font-size: 30rpx;
		line-height: 40rpx;
		color: #333333;
		image{
			width: 80rpx;
			height: 80rpx;
			margin-bottom: 12rpx;
			}
		}
	.title{
		padding: 0rpx 30rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 32rpx;
		font-weight: bold;
		line-height:40rpx;
		color: #333333;	
		image{
			width:36rpx;
			height:36rpx;
			margin-right: 16rpx;
			}
	}	
.pro-box{
	margin:20rpx 24rpx;
	background-color: #FFFFFF;
	padding: 24rpx 30rpx;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	border-radius:12rpx ;
	image{
		width: 240rpx;
		height: 200rpx;
		display: block;
		border-radius: 12rpx;
		}
	}
	.pro-right{
		display: flex;
		flex-direction:column;
		width:370rpx;
		}
	.ptitle{
		font-size: 28rpx;
		line-height: 30rpx;
		font-weight:600rpx;
		color: #333333;
		}
	.bp{
		width:130rpx;
		background-color:#ff6633;
		font-size: 24rpx;
		text-align: center;
		font-weight: 400;
		line-height: 32rpx;
		color: #FFFFFF;
		opacity: 1;
		padding: 3rpx 12rpx;
		margin: 16rpx 0rpx;
		border-radius: 10rpx;
	}
	.price{
		font-size: 30rpx;
		font-weight: 600;
		line-height: 40rpx;
		color: #EA5B0C;
		opacity: 1;
	}
	.serchList{
		background-color: #FFFFFF;
		margin: 0rpx 20rpx;
		}
	.ser-title{
		font-size: 28rpx;
		padding: 20rpx 24rpx;
		border-bottom: 1rpx solid #999999;
		text-align: left;
		}
	.search-box{
		background-color: #ff6633;
		padding: 20rpx;
		margin-bottom:32rpx;
	}	
</style>
